import React, { Component } from 'react'
import { createAppContainer, createStackNavigator } from 'react-navigation'
import Home from './src/Home.js'
import Line from './src/pages/Line'
import SearchCar from './src/pages/SearchCar'
import SearchDetails from './src/pages/SearchDetails'
import SiteDetails from './src/pages/SiteDetails'
import RoutePlan from './src/pages/RoutePlan'
import RoutePlanEntrance from './src/pages/RoutePlanEntrance'
import AddSearchName from './src/pages/AddSearchName'
import TimeTables from './src/pages/TimeTables'
import RouteDetails from './src/pages/RouteDetails'
import Collection from './src/pages/Collection'
import Correction from './src/pages/Correction'
import LoginStack from './loginmodule/routers/LoginRoutes'
import BusCardStack from './buscard/BusCardRoutes.js'
import OrderStack from './ordermodule/routers/OrderRoutes'
import NavigationService from './src/utils/NavigationService'
import MallStack from './mall/MallRoutes.js'
import NetErrorPage from './src/utils/NetErrorPage'

/** 公交测试路由 */
const BusStack = createStackNavigator({
  Main: SearchCar,
  SiteDetails,
  RoutePlanEntrance,
  SearchDetails,
  RoutePlan,
  Line,
  RouteDetails,
  AddSearchName,
  Collection,
  Correction,
  TimeTables
})

/** APP根路由 */
const AppStack = createStackNavigator(
  {
    Home: {
      screen: Home
    },
    Bus: {
      screen: BusStack
    },

    Card: {
      screen: BusCardStack
    },

    Login: {
      screen: LoginStack
    },
    Mall: {
      screen: MallStack
    },

    Order: {
      screen: OrderStack
    },

    NetError: {
      screen: NetErrorPage
    }
  },
  {
    mode: 'modal',
    headerMode: 'none',
    initialRouteName: 'Home'
  }
)

const AppContainer = createAppContainer(AppStack)

export default class App extends Component {
  render() {
    return (
      <AppContainer
        ref={navigatorRef => {
          NavigationService.setTopLevelNavigator(navigatorRef)
        }}
      />
    )
  }
}
